
import React from 'react'

class MessageSettingPictureEdit extends React.Component {
  constructor(props) {
    super(props)

    this.state = {
      data: {}
    }
  }

  componentWillReceiveProps(props) {
    this.setState({
      data: props.data
    })
  }

  onDataSubmit() {
    // var keyWord = $(this.refs.messageKeyWord).val(),
    //     id = $(this.refs.messageId).val() || (new Date().getTime());
    // var data = {
    //   id: id,
    //   keyWord: keyWord
    // }
    if (this.props.isEdit) {
      this.props.onDataUpdate(data)
    }else {
      this.props.onDataCreate(data)
    }
  }
  onChange(event, key) {
    var value = $(event.target).val();
    var data = this.state.data;
    data[key] = value;
    this.setState({
      data: data
    })
  }
  EnterClick(){
           var code = document.all ? window.event.keyCode : arguments.callee.caller.arguments[0].which;
           var e = e || window.event;
           if (code == "13") //enter键
           {
             e.preventDefault();
             console.log("cccc",4444);
           }
       }
  EnterPress(e){ //传入 event
    console.log("bbbb",2);
   var e = e || window.event;
   if(e.keyCode == 13){
      e.preventDefault();
      alert("aaag")
      console.log("aaaa",1);
     }
   }

  render() {
    var self = this;
    return (
      <div className="modal fade" id="DemoSettingEdit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div className="modal-dialog" role="document">
          <div className="modal-content">
            <div className="modal-header">
              <button type="button" className="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
              <h4 className="modal-title" id="demo-modal-label">选择图片</h4>
            </div>
            <div className="modal-body">
              <div className="form-group">
                <div className="message-eventkey-list">
                 <div className="innerMain">
                   <table className="table table-bordered tablePicture">

                     <tbody>
                      <tr>
                       <th className="innerSide">
                       </th>

                         <tr className="titleBar">
                            <button type="button" className="upLoad" onClick={(event)=>this.props.onAddEventPicButtonClick(event)}>本地上传</button>
                            <em className="pictureSize">大小不超过5M</em>
                         </tr>
                         <tr className="mainContent">

                         </tr>

                      </tr>
                     </tbody>
                   </table>
                 </div>
                </div>
              </div>
              <input ref="demoId" value={self.props.data.id} hidden/>

            </div>
            <div className="modal-footer">
              <button type="button" className="btn btn-default" data-dismiss="modal">取消</button>
              <button type="button" className="btn btn-primary"
                      onClick={(event)=> this.onDataSubmit()}>确定</button>
            </div>

          </div>
        </div>
      </div>
    )
  }
}

export default MessageSettingPictureEdit
